package com.rankeiot.core;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext;

public class Context {
    protected static ApplicationContext applicationContext;
    protected static ConfigurableListableBeanFactory beanFactory;
    /**
     * 获取类型为requiredType的对象
     *
     * @param clz
     * @return
     * @throws org.springframework.beans.BeansException
     *
     */
    public static <T> T getBean(Class<T> clz) throws BeansException
    {
        T result = beanFactory.getBean(clz);
        return result;
    }
    public static void publishEvent(Object event){
        applicationContext.publishEvent(event);
    }

    public static ApplicationContext getApplicationContext(){
        return applicationContext;
    }
}
